package com.upb.webserver.dao.mapper;

import com.upb.webserver.dao.entity.TbChainOrg;
import com.upb.webserver.dao.entity.TbChainOrgExample;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;

public interface TbChainOrgMapper {

    @Delete({ "delete from tb_chain_org", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    int deleteByChainId(@Param("chainId") Integer chainId);

    @Select({ "select", TbChainOrgSqlProvider.ALL_COLUMN_FIELDS, "from tb_chain_org", "where chain_id = #{chainId,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "org_type", property = "orgType", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbChainOrg> ListByChainId(@Param("chainId") Integer chainId);

    @Select({ "<script>", "select", TbChainOrgSqlProvider.ALL_COLUMN_FIELDS, "from tb_chain_org", "where org_id in", "<foreach collection='orgIdList' item='orgId' open='(' separator=',' close=')'>", "#{orgId}", "</foreach>", "</script>" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "org_type", property = "orgType", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbChainOrg> selectByOrgIdList(@Param("orgIdList") List<Integer> orgIdList);

    @Select({ "select", TbChainOrgSqlProvider.ALL_COLUMN_FIELDS, "from tb_chain_org", "where chain_id = #{chainId,jdbcType=INTEGER} and  org_id = #{orgId,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "org_type", property = "orgType", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbChainOrg> selectByChainAndOrg(@Param("chainId") Integer chainId, @Param("orgId") Integer orgId);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainOrgSqlProvider.class, method = "countByExample")
    long countByExample(TbChainOrgExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @DeleteProvider(type = TbChainOrgSqlProvider.class, method = "deleteByExample")
    int deleteByExample(TbChainOrgExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @Delete({ "delete from tb_chain_org", "where id = #{id,jdbcType=INTEGER}" })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @Insert({ "insert into tb_chain_org (chain_id, chain_type, ", "org_id, org_type, ", "gmt_create, gmt_modified, ", "description)", "values (#{chainId,jdbcType=INTEGER}, #{chainType,jdbcType=TINYINT}, ", "#{orgId,jdbcType=INTEGER}, #{orgType,jdbcType=TINYINT}, ", "#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP}, ", "#{description,jdbcType=LONGVARCHAR})" })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insert(TbChainOrg record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @InsertProvider(type = TbChainOrgSqlProvider.class, method = "insertSelective")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "id", before = false, resultType = Integer.class)
    int insertSelective(TbChainOrg record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainOrgSqlProvider.class, method = "selectByExampleWithBLOBs")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "org_type", property = "orgType", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    List<TbChainOrg> selectByExampleWithBLOBs(TbChainOrgExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainOrgSqlProvider.class, method = "selectByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "org_type", property = "orgType", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP) })
    List<TbChainOrg> selectByExample(TbChainOrgExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @Select({ "select", "id, chain_id, chain_type, org_id, org_type, gmt_create, gmt_modified, description", "from tb_chain_org", "where id = #{id,jdbcType=INTEGER}" })
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "org_type", property = "orgType", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    TbChainOrg selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainOrgSqlProvider.class, method = "updateByExampleSelective")
    int updateByExampleSelective(@Param("record") TbChainOrg record, @Param("example") TbChainOrgExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainOrgSqlProvider.class, method = "updateByExampleWithBLOBs")
    int updateByExampleWithBLOBs(@Param("record") TbChainOrg record, @Param("example") TbChainOrgExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainOrgSqlProvider.class, method = "updateByExample")
    int updateByExample(@Param("record") TbChainOrg record, @Param("example") TbChainOrgExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @UpdateProvider(type = TbChainOrgSqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(TbChainOrg record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @Update({ "update tb_chain_org", "set chain_id = #{chainId,jdbcType=INTEGER},", "chain_type = #{chainType,jdbcType=TINYINT},", "org_id = #{orgId,jdbcType=INTEGER},", "org_type = #{orgType,jdbcType=TINYINT},", "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},", "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP},", "description = #{description,jdbcType=LONGVARCHAR}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKeyWithBLOBs(TbChainOrg record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @Update({ "update tb_chain_org", "set chain_id = #{chainId,jdbcType=INTEGER},", "chain_type = #{chainType,jdbcType=TINYINT},", "org_id = #{orgId,jdbcType=INTEGER},", "org_type = #{orgType,jdbcType=TINYINT},", "gmt_create = #{gmtCreate,jdbcType=TIMESTAMP},", "gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}", "where id = #{id,jdbcType=INTEGER}" })
    int updateByPrimaryKey(TbChainOrg record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert({ "<script>", "insert into tb_chain_org (chain_id, ", "chain_type, org_id, ", "org_type, gmt_create, ", "gmt_modified, description)", "values<foreach collection=\"list\" item=\"detail\" index=\"index\" separator=\",\">(#{detail.chainId,jdbcType=INTEGER}, ", "#{detail.chainType,jdbcType=TINYINT}, #{detail.orgId,jdbcType=INTEGER}, ", "#{detail.orgType,jdbcType=TINYINT}, #{detail.gmtCreate,jdbcType=TIMESTAMP}, ", "#{detail.gmtModified,jdbcType=TIMESTAMP}, #{detail.description,jdbcType=LONGVARCHAR})</foreach></script>" })
    int batchInsert(List<TbChainOrg> list);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table tb_chain_org
     *
     * @mbg.generated
     */
    @SelectProvider(type = TbChainOrgSqlProvider.class, method = "getOneByExample")
    @Results({ @Result(column = "id", property = "id", jdbcType = JdbcType.INTEGER, id = true), @Result(column = "chain_id", property = "chainId", jdbcType = JdbcType.INTEGER), @Result(column = "chain_type", property = "chainType", jdbcType = JdbcType.TINYINT), @Result(column = "org_id", property = "orgId", jdbcType = JdbcType.INTEGER), @Result(column = "org_type", property = "orgType", jdbcType = JdbcType.TINYINT), @Result(column = "gmt_create", property = "gmtCreate", jdbcType = JdbcType.TIMESTAMP), @Result(column = "gmt_modified", property = "gmtModified", jdbcType = JdbcType.TIMESTAMP), @Result(column = "description", property = "description", jdbcType = JdbcType.LONGVARCHAR) })
    Optional<TbChainOrg> getOneByExample(TbChainOrgExample example);
}
